<template>
  <div>

  <p style="font-size: xx-large">增加项目</p>
  <form style="margin: 0px 70px" class="nonBlur">
    <div class="el-row" style="margin-bottom: 2px">
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <small class="form-text text-muted">项目id</small>-->
        <input type="text" class="form-control mb-2" v-model="pId" id="inlineFormInput" placeholder="项目id">
      </div>
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <small class="form-text text-muted">项目名称</small>-->
        <input type="text" class="form-control mb-2" v-model="pName" id="inlineFormInputGroup" placeholder="项目名称">
      </div>
      <div class="el-col-md-4 el-col-push-4" style="margin: 5px">
<!--        <small class="form-text text-muted">项目创建日期</small>-->
<!--        <input type="text" class="form-control" placeholder="项目创建日期">-->
        <el-date-picker type="daterange" v-model="pDate" start-placeholder="start" end-placeholder="end">

        </el-date-picker>
      </div>
    </div>
    <div class="el-row" style="margin-bottom: 2px">
      <div class="el-col-md-6 el-col-push-3" style="margin: 5px">
<!--        <label>项目类型</label>-->
<!--        <input type="text" class="form-control" placeholder="项目类型">-->
        <select class="form-control" v-model="pType" placeholder="项目类型">
          <option>---请选择---</option>
          <option>0.大型</option>
          <option>1.中型</option>
          <option>2.小型</option>
          <option>3.微型</option>
        </select>
      </div>

      <div class="el-col-md-6 el-col-push-7" style="margin: 5px">
<!--        <label>客户id</label>-->
        <input type="text" class="form-control" v-model="cId" placeholder="客户id">
      </div>
    </div>
    <div class="el-row" style="margin-bottom: 2px">
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>项目模型主管id</label>-->
        <input type="text" class="form-control" v-model="pModelManagerId" placeholder="项目模型主管id">
      </div>
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>模型人员</label>-->
        <input type="text" class="form-control" v-model="pModelStaff" placeholder="模型人员">
      </div>
      <div class="el-col-md-4 el-col-push-4" style="margin: 5px">
<!--        <label>项目渲染主管id</label>-->
        <input type="text" class="form-control"  v-model="pRenderManagerId" placeholder="项目渲染主管id">
      </div>
      <div class="el-col-md-4 el-col-push-4" style="margin: 5px">
<!--        <label>渲染人员</label>-->
        <input type="text" class="form-control"  v-model="pRenderStaff" placeholder="渲染人员">
      </div>
    </div>

    <div class="el-row" style="margin-bottom: 2px">
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>项目后期主管id</label>-->
        <input type="text" class="form-control" v-model="pAfterManagerId" placeholder="项目后期主管id">
      </div>
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>后期人员</label>-->
        <input type="text" class="form-control" v-model="pAfterStaff" placeholder="后期人员">
      </div>
      <div class="el-col-md-8 el-col-push-4" style="margin: 5px">
        <!--        <label>项目名称</label>-->
        <input type="text" class="form-control" v-model="pFileUrl" placeholder="项目文件仓库URL">
      </div>
    </div>

    <div class="el-row">

      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>项目名称</label>-->
        <input type="text" class="form-control" v-model="pModelWage" placeholder="模型部分工资">
      </div>
      <div class="el-col-md-4 el-col-push-2" style="margin: 5px">
<!--        <label>项目名称</label>-->
        <input type="text" class="form-control" v-model="pRenderWage" placeholder="渲染部分工资">
      </div>
      <div class="el-col-md-4 el-col-push-4" style="margin: 5px">
<!--        <label>项目名称</label>-->
        <input type="text" class="form-control" v-model="pAfterWage" placeholder="后期部分工资">
      </div>
    </div>
    <input type="button" @click="submitProject" value="submit">
<!--    <div class="col-auto" style="margin-top: 10px">-->
<!--      <button class="btn btn-primary" @click="submitProject">Submit</button>-->
<!--    </div>-->

  </form>
  </div>
</template>

<script>
  import Global from '../../utils/global'

  export default {
    name: 'AddProject',
    data () {
      return {
        glo:new Global,
        pId:null,
        pName:null,
        pDate:null,
        pType:null,
        cId:null,
        pModelManagerId:null,
        pModelStaff:null,
        pRenderManagerId:null,
        pRenderStaff:null,
        pAfterManagerId:null,
        pAfterStaff:null,
        pFileUrl:null,
        pModelWage:null,
        pRenderWage:null,
        pAfterWage:null,
      }
    },
    methods: {
      handleSubmitProject (res) {
        console.log(res);
        let feedBack = eval(res);
        if (feedBack.success == false) {//登录失败
          this.$message("创建失败");
          return;
        }
        this.$message.success("项目添加成功√")
        return;
      },
      dateToSend(localeTime){
        var temp = localeTime.split(' ')
        temp = temp[0]
        temp = temp.split('/')
        if(temp[1]=="1" || temp[1]=="2" || temp[1]=="3" || temp[1]=="4" || temp[1]=="5" ||
          temp[1]=="6" || temp[1]=="7" || temp[1]=="8" || temp[1]=="9" ){
          temp[1] = "0"+temp[1]
        }
        if(temp[2]=="1" || temp[2]=="2" || temp[2]=="3" || temp[2]=="4" || temp[2]=="5" ||
          temp[2]=="6" || temp[2]=="7" || temp[2]=="8" || temp[2]=="9" ){
          temp[2] = "0"+temp[2]
        }

        return ""+temp[0]+"-"+temp[1]+"-"+temp[2]+" 12:00:00"
      },
      submitProject () {
        var project = {
          pId:null,
          pName:null,
          pCreateDate:null,
          pEndDate:null,
          pType:null,
          cId:null,
          pModelManagerId:null,
          pModelStaff:null,
          pRenderManagerId:null,
          pRenderStaff:null,
          pAfterManagerId:null,
          pAfterStaff:null,
          pPeriodStatus:null,
          pProjectStatus:null,
          pFileUrl:null,
          pModelWage:null,
          pRenderWage:null,
          pAfterWage:null,
        }
        project.pId = eval(this.pId);
        project.pName=this.pName;
        // var c=""+this.pDate[0].getFullYear()+ "-" +this.pDate[0].getMonth()+ "-" +this.pDate[0].getDate();
        // var d=""+this.pDate[1].getFullYear()+ "-" +this.pDate[1].getMonth()+ "-" +this.pDate[1].getDate();

        project.pCreateDate=this.dateToSend(this.pDate[0].toLocaleString())
        // project.pEndDate=this.pDate[1].toLocaleString();
        project.pEndDate =this.dateToSend(this.pDate[1].toLocaleString())

        project.pType=eval(this.pType.split('.')[0]);
        project.cId=eval(this.cId);
        project.pModelManagerId=eval(this.pModelManagerId);
        project.pModelStaff=this.pModelStaff;
        project.pRenderManagerId=eval(this.pRenderManagerId);
        project.pRenderStaff=this.pRenderStaff;
        project.pAfterManagerId=eval(this.pAfterManagerId);
        project.pAfterStaff=this.pAfterStaff;
        project.pFileUrl=this.pFileUrl;
        project.pModelWage=eval(this.pModelWage);
        project.pRenderWage=eval(this.pRenderWage);
        project.pAfterWage=eval(this.pAfterWage);
        project.pPeriodStatus=1,
          // 1是创建了，啥都没做，
        project.pProjectStatus=3
          // 3是进行中
        console.log(project)
        // console.log("toLocaleTimeString: "+this.pDate[0].toLocaleTimeString())
        // console.log("toLocaleString: "+this.pDate[0].toLocaleString())
        // console.log("toJSON: "+this.pDate[0].toJSON())
        // console.log("toDateString: "+this.pDate[0].toDateString())
        this.glo.sendDate(this.glo.server + "manager/createProject", project, this.handleSubmitProject,"POST")
      }
    }
  }
</script>

<style scoped>
  ::-webkit-input-placeholder{
    font-family:PingFang SC;
  }

</style>
